/**
 * Copyright(C) 2012 Luvina Software Company
 *
 * MstGroupLogicImpl.java, 7/1/2013, bacdv
 */
package net.luvina.manageuser.logic.impl;

import java.util.ArrayList;
import java.util.List;

import javax.faces.model.SelectItem;

import net.luvina.manageuser.dao.MstJapanDao;
import net.luvina.manageuser.hibernate.MstJapan;
import net.luvina.manageuser.logic.MstJapanLogic;
import net.luvina.manageuser.util.ConfigProperties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service("mstJapanLogic")
@Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.DEFAULT, readOnly = false, rollbackFor = { Throwable.class })
public class MstJapanLogicImpl implements MstJapanLogic {
    @Autowired
    private MstJapanDao mstJapanDao;

    /*
     * (non-Javadoc)
     *
     * @see
     * net.luvina.manageuser.logic.MstJapanLogic#getListItemJapan(java.lang.
     * String)
     */
    public List<SelectItem> getListItemJapan(String str) {
        List<SelectItem> selectItems = new ArrayList<SelectItem>();
        SelectItem item = new SelectItem();
        item.setValue("0");
        item.setLabel(ConfigProperties.getData("please_select"));
        selectItems.add(item);

        List<MstJapan> mstJapans = mstJapanDao.getListJapan();
        if (mstJapans != null && mstJapans.size() > 0) {
            for (int i = 0; i < mstJapans.size(); i++) {
                MstJapan japan = mstJapans.get(i);
                SelectItem item2 = new SelectItem();
                item2.setValue(japan.getCodeLevel());
                item2.setLabel(japan.getNameLevel());
                selectItems.add(item2);
            }
        }
        return selectItems;
    }

    /*
     * (non-Javadoc)
     *
     * @see
     * net.luvina.manageuser.logic.MstJapanLogic#existMstJapan(java.lang.String)
     */
    public boolean existMstJapan(String str) {
        // TODO Auto-generated method stub
        return false;
    }
}
